<?php
/*
 * @Author       : lovefc
 * @Date         : 2021-04-06 09:00:20
 * @LastEditTime : 2021-04-16 16:21:19
 */

namespace Main\Api\App;

class view extends common
{
	// 读取对应模板
	public function readtemplate($template_name)
	{
		$this->views($template_name);
	}

	// 首页
	public function index()
	{
		$this->views('index');
	}

	// 文章页
	public function article($id = 0)
	{
		$this->assign('aid', $id);
		$res = $this->articles_model->getKeyword($id);
		if ($res) {
			$this->assign('title', $res['title'] . '-' . $this->config['title']);
			$this->assign('keywords', $res['keyword']);
			$this->assign('description', $res['description']);
		}
		// 获取cookies
		$status = \FC\Input($this->COOKIES->path('/')->get('view' . $id));
		if (!$status) {
			$data = array('readnum' => 'readnum+1');
			$this->articles_model->update_readnum($id);
			$this->COOKIES->path('/')->expire(86400)->set('view' . $id, $id);
		}
		$this->views('view');
	}

	// 分类列表
	public function article_list()
	{
		$this->assign('title', '分类列表-' . $this->config['title']);
		$this->views('class');
	}

	// 推荐文章
	public function recommend()
	{
		$this->assign('title', '推荐文章-' . $this->config['title']);
		$this->assign('keywords', '一些推荐给大家的文章');
		$this->assign('description', '好东西,就要推荐给大家');		
		$this->views('recommend');
	}

	// 微语
	public function weiyu()
	{
		$this->assign('title', '心情说说-' . $this->config['title']);
		$this->assign('keywords', '探听来由说详细,此事说来尽不知');
		$this->assign('description', '做人嘛,最重要的是开心');				
		$this->views('weiyu');
	}

	// 友链
	public function links()
	{
		$this->assign('title', '我的邻居-' . $this->config['title']);
		$this->assign('keywords', '领座有何人,何人不自知');
		$this->assign('description', '努力做一个优秀的人');		
		$this->views('link');
	}
	// 关于
	public function about()
	{
		$this->assign('title', '关于自己-' . $this->config['title']);
		$this->assign('keywords', '平安喜顺,驾驭此生');
		$this->assign('description', '鸿雁不曾低处去,杰人自有出头时');			
		$this->views('about');
	}
}
